<html>
<head><meta charset="utf-8"><title>multiple snippet edits · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/multiple.20snippet.20edits.html">multiple snippet edits</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="236705648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/multiple%20snippet%20edits/near/236705648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Manmeet Singh <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/multiple.20snippet.20edits.html#236705648">(Apr 29 2021 at 16:37)</a>:</h4>
<p>Looks like multiple edits with snippet edits are not supported by vscode, lsp-mode, +maybe more</p>



<a name="236706044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/multiple%20snippet%20edits/near/236706044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Manmeet Singh <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/multiple.20snippet.20edits.html#236706044">(Apr 29 2021 at 16:40)</a>:</h4>
<p>I just wanted make extract to function better</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="cp">$</span><span class="mi">0</span><span class="s">"text"</span><span class="cp">$</span><span class="mi">0</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>to </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">     </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="cp">$</span><span class="p">{</span><span class="mi">0</span>:<span class="nc">fun_name</span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="cp">$</span><span class="p">{</span><span class="mi">0</span>:<span class="nc">fun_name</span><span class="p">}()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="s">"text"</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="236706408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/multiple%20snippet%20edits/near/236706408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/multiple.20snippet.20edits.html#236706408">(Apr 29 2021 at 16:42)</a>:</h4>
<p>yeah, this is missing in the LSP unfortunately</p>



<a name="236706461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/multiple%20snippet%20edits/near/236706461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Manmeet Singh <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/multiple.20snippet.20edits.html#236706461">(Apr 29 2021 at 16:43)</a>:</h4>
<p>so this is a lsp limitation?</p>



<a name="236706520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/multiple%20snippet%20edits/near/236706520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/multiple.20snippet.20edits.html#236706520">(Apr 29 2021 at 16:43)</a>:</h4>
<p>yes</p>



<a name="236706556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/multiple%20snippet%20edits/near/236706556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/multiple.20snippet.20edits.html#236706556">(Apr 29 2021 at 16:44)</a>:</h4>
<p>I believe it only supports snippets in completion, not assists</p>



<a name="236706613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/multiple%20snippet%20edits/near/236706613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/multiple.20snippet.20edits.html#236706613">(Apr 29 2021 at 16:44)</a>:</h4>
<p>our use of snippets in assists is an extension</p>



<a name="236706703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/multiple%20snippet%20edits/near/236706703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Manmeet Singh <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/multiple.20snippet.20edits.html#236706703">(Apr 29 2021 at 16:44)</a>:</h4>
<p>lsp-mode is supporting it too, but only one snippet replacement/edit at a time</p>



<a name="236706841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/multiple%20snippet%20edits/near/236706841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/multiple.20snippet.20edits.html#236706841">(Apr 29 2021 at 16:45)</a>:</h4>
<p>yeah, same as our client-side implementation in VS Code</p>



<a name="236707023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/multiple%20snippet%20edits/near/236707023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/multiple.20snippet.20edits.html#236707023">(Apr 29 2021 at 16:47)</a>:</h4>
<p>I think in order to fix this, a full client implementation needs to be upstreamed into VS Code, and its editor might need to be changed for that (it only allows using a single TextEdit with multiple snippets, not snippets in multiple TextEdits)</p>



<a name="236707098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/multiple%20snippet%20edits/near/236707098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/multiple.20snippet.20edits.html#236707098">(Apr 29 2021 at 16:47)</a>:</h4>
<p>And then the LSP extension should be relatively easy to build on top of that</p>



<a name="236707106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/multiple%20snippet%20edits/near/236707106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Manmeet Singh <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/multiple.20snippet.20edits.html#236707106">(Apr 29 2021 at 16:47)</a>:</h4>
<p>I wonder how easy will be hacking this together in emacs <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="236708317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/multiple%20snippet%20edits/near/236708317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/multiple.20snippet.20edits.html#236708317">(Apr 29 2021 at 16:55)</a>:</h4>
<p>this will be pretty complicated if you want to have connected fields between different text edits, I think</p>



<a name="236708800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/multiple%20snippet%20edits/near/236708800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Manmeet Singh <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/multiple.20snippet.20edits.html#236708800">(Apr 29 2021 at 16:59)</a>:</h4>
<p>I would assume IntelliJ already has some like this</p>



<a name="236712204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/multiple%20snippet%20edits/near/236712204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/multiple.20snippet.20edits.html#236712204">(Apr 29 2021 at 17:21)</a>:</h4>
<p>You might be able to get around it with a combination of snippets and textDocument/linkedEditingRange but that would involve a separate request</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>